﻿using Microsoft.AspNetCore.Mvc.Filters;

namespace StoreISet
{
    /// <summary>
    /// 全局异常过滤器
    /// </summary>
    public class MyGlobalExceptionFilter : IExceptionFilter
    {
        public readonly ILogger<MyGlobalExceptionFilter> _logger;
        public MyGlobalExceptionFilter(ILogger<MyGlobalExceptionFilter> logger)
        {
            _logger = logger;
        }
        public void OnException(ExceptionContext context)
        {
            _logger.LogError($"全局异常信息:{context.Exception.StackTrace}");
        }
    }
}
